package com;



import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableEurekaClient
// feign客户端注解,并指定要扫描的包以及配置接口DeptClientService
@EnableFeignClients(basePackages = {"com.xt.springcloud"})
@EnableCircuitBreaker//把信息给监控中心
public class CustomerFeignApplication {
    public static void main(String[] args) {
        SpringApplication.run(CustomerFeignApplication.class, args);
    }

//    @Bean
//    @LoadBalanced//开启负载均衡
//    public RestTemplate getRestTemplate() {
//        return new RestTemplate();
//    }

//    @Bean
//    public IRule myRule() {
//        return new RandomRule();//使用随机策略
//        //return new RoundRobinRule();//使用轮询策略
//        //return new AvailabilityFilteringRule();//使用轮询策略
//        //return new RetryRule();//使用轮询策略
//    }

//    @Bean
//    public ServletRegistrationBean hystrixMetricsStreamServlet(){
//        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
//        //访问该页面就是监控页面
//        registrationBean.addUrlMappings("/actuator/hystrix.stream");
//
//        return registrationBean;
//    }

}
